package com.errol.generic.file.core.pojo;

/**
 * Created by Errol on 17/4/16.
 *
 * @author zhang xiao bin
 * @version v1.0
 * @date 2020/10/21
 * @since v4.7.6
 */
public enum FileExtension {

    /**
     * 文件扩展
     */
    JPG(".jpg"),
    JPEG(".jpeg"),
    PNG(".png"),
    GIF(".gif"),
    TXT(".txt"),
    DOC(".doc"),
    DOCX(".docx"),
    XLS(".xls"),
    XLSX(".xlsx"),
    PPT(".ppt"),
    PPTX(".pptx"),
    XML(".xml"),
    PDF(".pdf"),
    ZIP(".zip"),
    GZ(".gz"),
    JSON(".json"),
    MP3(".mp3"),
    AAC(".aac"),
    M4A(".m4a"),
    WMA(".wma"),
    WAV(".wav"),
    MP4(".mp4"),
    HTML(".html")
    ;
    private final String extension;

    FileExtension(String extension) {
        this.extension = extension;
    }

    public String getExtension() {
        return extension;
    }

    public static FileExtension resolve(String extension) {
        if (extension != null) {
            extension = extension.toUpperCase();
            for (FileExtension value : FileExtension.values()) {
                if (value.name().equals(extension)) {
                    return value;
                }
            }
        }
        return null;
    }
}
